/**
 * 退出登录
 */
function loginout() {
	if (confirm('确定退出?')) {
		window.location.href = "../login/loginout";
	}
}

$(function() {
    debugger;
	//查询菜单权限
    $(".sub-menu").hide();
    $(".sub-menu ul li").hide();

    var param= {

    };
    Ajax.ajax({
        url:"/index/getStaff",
        data: param,
        type: "POST",
        dataType: 'json',
        async:false,
        success:function(res){
            debugger;

            if (res.resultCode == 0) {

                $("#staffId").val(res.data.staff_id);
                $("#loginMsg").html("欢迎回来,"+res.data.staff_code);
            }else{
            }
        }

    });

    var staffId = $("#staffId").val();
    if(staffId== ""){
        top.location.href= "/index";
        return;
    }

    var param= {

        staffId:$("#staffId").val()==""?"1":$("#staffId").val()
    };
    Ajax.ajax({
        url:"/staff/queryMenuByStaffId",
        data: param,
        type: "POST",
        dataType: 'json',
        async:false,
        success:function(res){
            debugger;

            if (res.resultCode == 0) {
                for(var i=0;i< res.data.length ;i++){
                    var menuCode = res.data[i].menu_code;

                    $("#"+menuCode).parents(".sub-menu").show();
                    $("#"+menuCode).show();
                }


            }else{
            }
        }

    });



	// $('#main-content').load('/newshop/demo/hdqd_analysis2.html');

    $('#main-content').load('/base/base');
	debugger;
	$(".sub-menu li", $('#leftside-navigation')).click(
		function() {
			var id = $(this).attr("id");
			var directory = '';
			switch (id){
				case 'fast':$('#main-content').load('/base/base');break;
				case 'usermanger': $('#main-content').load('/newshop/user/user.html');break;
				case 'admin':$('#main-content').load('/newshop/user/admin.html?399');break;
				case 'offermanger':$('#main-content').load('/newshop/offer/goods/goods.html?123123');break;
				case 'classify':$('#main-content').load('/newshop/offer/classify/classify.html?123123');break;
				case 'book':$('#main-content').load('/newshop/artcle/image/image.html');break;
				case 'video':$('#main-content').load('/newshop/artcle/video/video.html');break;
				case 'ordermanger':$('#main-content').load('/newshop/order/order/order.html');break;
				case 'comment':$('#main-content').load('/newshop/order/comment/comment.html');break;
				case 'moneymanger':$('#main-content').load('/newshop/cash/cash.html');break;
				case 'ad':$('#main-content').load('/newshop/system/ad/ad.html');break;
				case 'join':$('#main-content').load('/newshop/system/joinfee/join.html');break;
				case 'about':$('#main-content').load('/system/qryAboutUs');break;
				case 'base':$('#main-content').load('/system/qryBase');break;
				case 'message':$('#main-content').load('/newshop/system/message/message.html');break;

			}
		});
});